Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make extended commit info third injected tx #1791

Open
wants to merge 5 commits into
base: feat/oracle
Choose a base branch
from

Conversation

noot
Copy link
Collaborator

@noot noot commented Nov 6, 2024

Summary

make extended commit info third injected tx, and update SequencerBlock::try_from_block_info_and_data to handle whether the extended commit info is in the block or not.

Background

it makes more sense to append to the existing list of injected txs which are the two commitments at the start of the block.

Changes

  • make extended commit info the third injected tx instead of the first
  • update SequencerBlock::try_from_block_info_and_data to handle whether the extended commit info is in the block or not
  • cleanup of related unit tests

Testing

unit tests

Breaking Changelist

  • unbreaks SequencerBlock::try_from_block_info_and_data

@noot noot requested a review from a team as a code owner November 6, 2024 20:02
@noot noot requested a review from Fraser999 November 6, 2024 20:02
@github-actions github-actions bot added the sequencer pertaining to the astria-sequencer crate label Nov 6, 2024
@@ -772,6 +772,10 @@ impl SequencerBlock {
/// # Panics
///
/// - if a rollup data merkle proof cannot be constructed.
#[expect(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this into a builder.

Needing all the arguments is not a good reason to ignore the lint.

@@ -1042,6 +1045,16 @@ fn take_initial_elements_from_data(
`data` used to construct the tree",
);

let extended_commit_info = if with_extended_commit_info {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assigned variable is never used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needs to be taken out of the iter either way, and next PR i will be using this value in SequencerBlock. should i still remove from here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine to leave as is since this is being merged to a feature branch rather than main.

Copy link
Contributor

@Fraser999 Fraser999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor non-blocking suggestion.

@@ -1042,6 +1045,16 @@ fn take_initial_elements_from_data(
`data` used to construct the tree",
);

let extended_commit_info = if with_extended_commit_info {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine to leave as is since this is being merged to a feature branch rather than main.

Comment on lines 525 to +532
let res = generate_rollup_datas_commitment(&signed_txs_included, deposits);

let txs = match encoded_extended_commit_info {
Some(encoded_extended_commit_info) => {
std::iter::once(encoded_extended_commit_info.into())
.chain(res.into_iter().chain(included_tx_bytes))
.collect()
}
Some(encoded_extended_commit_info) => res
.into_iter()
.chain(std::iter::once(encoded_extended_commit_info.into()))
.chain(included_tx_bytes)
.collect(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An Option can be turned into an iterator with 0 or 1 iterations via into_iter, so we can shorten this a little:

        // generate commitment to sequence::Actions and deposits and commitment to the rollup IDs
        // included in the block, chain on the extended commit info if `Some`, and finally chain on
        // the tx bytes.
        let txs = generate_rollup_datas_commitment(&signed_txs_included, deposits)
            .into_iter()
            .chain(encoded_extended_commit_info.map(Bytes::from).into_iter())
            .chain(included_tx_bytes)
            .collect();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants